<template>
  <div class="sidebar">
    <div class="logo">dgw</div>
    <div
      class="sidebar-item"
      :class="{'active': selectedMenu === 'downloading'}"
      @click="selectMenu('downloading')"
    >
      <font-awesome-icon :icon="['fas','download']" /> 正在下载
    </div>
    <div
      class="sidebar-item"
      :class="{'active': selectedMenu === 'waiting'}"
      @click="selectMenu('waiting')"
    >
      <font-awesome-icon :icon="['fas','hourglass-start']" /> 下在等待
    </div>
    <div
      class="sidebar-item"
      :class="{'active': selectedMenu === 'completed'}"
      @click="selectMenu('completed')"
    >
      <font-awesome-icon :icon="['fas','check']" /> 已完成/已停止
    </div>
    <hr class="sidebar-sep" />
    <div class="sidebar-item" :class="{'active': selectedMenu === 'http-settings'}" @click="selectMenu('http-settings')">
      <font-awesome-icon :icon="['fas','gear']" /> http设置
    </div>
    <div class="sidebar-item" :class="{'active': selectedMenu === 'bt-settings'}" @click="selectMenu('bt-settings')">
      <font-awesome-icon :icon="['fas','gears']" /> bt设置
    </div>
    <div class="sidebar-item" :class="{'active': selectedMenu === 'system-settings'}" @click="selectMenu('system-settings')">
      <font-awesome-icon :icon="['fas','sliders']" /> 系统设置
    </div>
  </div>
</template>

<script setup>
import { ref, defineEmits } from 'vue';

const emit = defineEmits(['menu-selected']);
const selectedMenu = ref('downloading');

const selectMenu = (menu) => {
  selectedMenu.value = menu;
  emit('menu-selected', menu);
};
</script>

<style scoped>
.sidebar {
  width: 200px;
  background-color: #1a2327;
  display: flex;
  flex-direction: column;
  color: var(--text-color);
  height: 100%;
}

.logo {
  font-size: 18px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
  background-color: #1e88e5;
  color: white;
  padding: 0 16px;
  -webkit-app-region: drag;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  color: var(--text-color);
  text-decoration: none;
}

.sidebar-item:hover {
  background-color: var(--hover-bg);
}

.sidebar-item.active {
  background-color: var(--active-bg);
  border-right: 2px solid var(--primary-color);
}

.sidebar-item .icon {
  margin-right: 8px;
}

/* separator */
.sidebar-sep {
  border: none;
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 10px 0;
}
</style>
